NEW_USER_ANALYSIS_CONFIG = {
    'real_time_report': False,
    'interval_type_list': ['day'],
    'target_event_id': ['active', 'register', 'recharge'],
    'day_to_calc': [0, 1],
    'group_by': '_chn.keyword',
    'values': [
        {
            "value_id": "new_device",
            "target_value": "_aid.keyword",
            "value_name": "新增设备",
            "filter": [
                {'term': {'_event_id': 'active'}},
                {'term': {"_is_new_device": 1}}
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "register_device",
            "target_value": "_aid.keyword",
            "value_name": "注册设备",
            "filter": [
                {'term': {'_event_id': 'active'}},
                {'term': {"_is_new_user": 1}},
                {'term': {"_is_new_device": 1}}
            ],
            "operation": "value_count",
            "value_type": "long"
        },
        {
            "value_id": "register_user",
            "target_value": "_user_id",
            "value_name": "注册账号",
            "filter": [
                {'term': {'_event_id': 'register'}}
            ],
            "operation": "value_count",
            "value_type": "long"
        },
        {
            "value_id": "register_rate",
            "value_name": "账号注册率",
            "value_expr": "register_user / new_device",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100))
        },
        {
            "value_id": "device_stay_2",
            "target_value": "_aid.keyword",
            "value_name": "设备次留",
            "filter": [
                {"term": {"_event_id": "active"}},
                {"term": {"_device_active_days": 1}}
            ],
            "time_range": {
                "_event_time": [1, 1]
            },
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "user_stay_2",
            "target_value": "_user_id",
            "value_name": "账号次留",
            "filter": [
                {"term": {"_event_id": "active"}},
                {"term": {"_active_days": 1}}
            ],
            "time_range": {
                "_event_time": [1, 1]
            },
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "recharge_new_user",
            "target_value": "_user_id",
            "value_name": "新付费账号",
            "filter": [
                {"term": {"_event_id": "recharge"}},
                {"term": {"_is_new_user": 1}}
            ],
            "operation": "cardinality",
            "value_type": "long",
        },
        {
            "value_id": "new_user_recharge_rate",
            "value_name": "新付费率",
            "value_expr": "recharge_new_user / register_user",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100))
        },
        {
            "value_id": "new_user_recharge_price",
            "target_value": "recharge_price",
            "value_name": "新付费金额",
            "filter": [
                {"term": {"_event_id": "recharge"}},
                {"term": {"_is_new_user": 1}}
            ],
            "value_type": "float",
            "adjust_amount": True,
        },
        {
            "value_id": "new_user_recharge_arpu",
            "value_name": "新付费arpu",
            "value_expr": "new_user_recharge_price / recharge_new_user",
            "adjust_amount": True,
        }
    ]
}
